package cn.com.mds.dao.impl;

import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import cn.com.mds.dao.BaseDao;

@Repository
public class BaseDaoImpl<T> implements BaseDao<T> {
	
	@Autowired
	private SessionFactory sessionFactory;
	
	
	private Session getSession(){
		return sessionFactory.getCurrentSession();
	}

	public boolean insert(T t) {
		return getSession().save(t) != null;
	}

	@SuppressWarnings("deprecation")
	public List<T> getList(String hql) {
		return getSession().createQuery(hql).list();
	}
	
	
	
}
